package com.faxsun.core.offer.service;

import java.util.List;

import javax.annotation.Resource;

import org.broadleafcommerce.common.util.TransactionUtils;
import org.broadleafcommerce.core.offer.dao.CustomerOfferDao;
import org.broadleafcommerce.core.offer.domain.CustomerOffer;
import org.broadleafcommerce.profile.core.domain.Customer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("fsCustomerOfferService")
public class CustomerOfferServiceImpl implements CustomerOfferService {
	
	@Resource(name = "blCustomerOfferDao")
	CustomerOfferDao customerOfferDao;

	@Override
	@Transactional(TransactionUtils.DEFAULT_TRANSACTION_MANAGER)
	public CustomerOffer createCustomerOffer() {
		return customerOfferDao.create();
	}

	@Override
	@Transactional(TransactionUtils.DEFAULT_TRANSACTION_MANAGER)
	public CustomerOffer saveCustomerOffer(CustomerOffer customerOffer) {
		return customerOfferDao.save(customerOffer);
	}

	@Override
	@Transactional(TransactionUtils.DEFAULT_TRANSACTION_MANAGER)
	public void deleteCustomerOffer(CustomerOffer customerOffer) {
		customerOfferDao.delete(customerOffer);
	}

	@Override
	public List<CustomerOffer> findCustomerOffersByCustomer(final Customer customer) {
		return customerOfferDao.readCustomerOffersByCustomer(customer);
	}

}
